<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World!</title>
<script type="text/javascript">
var xml;

function sayStaticHello() {
	sayHello("hello.txt")
}

function sayDynamicHello() {
	sayHello("hello.jsp")
}

function sayHello(url) {
	var xhr = new XMLHttpRequest()
	xhr.open('GET', url, true)
	xhr.onreadystatechange = function() {
		xml = xhr.responseText
		if (xhr.readyState == 4) alert(xhr.responseText)
	}
	xhr.send(null)
}
</script>
</head>
<body>
<ul>
<li>
<a href="javascript:sayStaticHello()">Click Me to view static Hello World</a>
</li>
<li>
<a href="javascript:sayDynamicHello()">Click Me to view dynamic Hello World</a>
</li>
<li>
<a href="javascript:alert(xml)">Click Me to view XMLHttpRequest</a>
</li>
</ul>
</body>
</html>